package com.agileai.bpm.controller.instance;

import java.util.List;

import com.agileai.bpm.bizmoduler.emulation.ProcessListSelect;
import com.agileai.domain.DataParam;
import com.agileai.domain.DataRow;
import com.agileai.hotweb.controller.core.PickFillModelHandler;
import com.agileai.hotweb.domain.core.User;
import com.agileai.hotweb.renders.LocalRenderer;
import com.agileai.hotweb.renders.ViewRenderer;

public class ProcessListSelectListHandler
        extends PickFillModelHandler {
    public ProcessListSelectListHandler() {
        super();
        this.serviceId = buildServiceId(ProcessListSelect.class);
    }
    
    public ViewRenderer prepareDisplay(DataParam param){
		mergeParam(param);
		initParameters(param);
		this.setAttributes(param);
		User user = (User) this.getUser();
		if(!"admin".equals(user.getUserCode())){
			param.put("currentUserCode", user.getUserCode());
		}
		List<DataRow> rsList = getService().queryPickFillRecords(param);
		this.setRsList(rsList);
		processPageAttributes(param);
		return new LocalRenderer(getPage());
	}

    protected void processPageAttributes(DataParam param) {
    }

    protected void initParameters(DataParam param) {
        initParamItem(param, "processName", "");
    }

    protected ProcessListSelect getService() {
        return (ProcessListSelect) this.lookupService(this.getServiceId());
    }
}
